<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-row>
        <el-col :span="4">
          <el-form-item>
            <el-input v-model="dataForm.obankid" placeholder="机构网点号" clearable></el-input>
          </el-form-item>
        </el-col>
                <el-col :span="4">
            <el-form-item>
            <el-input v-model="dataForm.serviceno" placeholder="业务件号" clearable></el-input>
            </el-form-item>
         </el-col>
  
         <el-col :span="4">
            <el-form-item>
              <el-input v-model="dataForm.realtyno" placeholder="不动产登记证明号" clearable></el-input>
            </el-form-item>
         </el-col>


         <el-col :span="6">
           <el-select v-model="dataForm.isdygh" placeholder="抵押类型" clearable style="width:95%" >
              <el-option
                v-for="item in dataForm.isDyghList"
                :key="item.value"
                :label="item.text"
                :value="item.value">
              </el-option>
          </el-select>
         </el-col>

        <el-col :span="6">
                <el-form-item>
                <el-button type="primary"  @click="getDataList()">本地查询</el-button>
                <el-button type="primary" @click="export2Excel('table')">导出</el-button> 
                <el-button v-if="isAuth('bdc:bdcrealtyinfo:save')" type="primary" @click="dyQueryHandle()">抵押查询</el-button>

              </el-form-item>
        </el-col>

      </el-row>
    </el-form>

<el-table
      :data="dataList"
      border
      id="table"
      style="display:none;width: 100%;">

      <el-table-column
        prop="seqno"
        header-align="center"
        align="center"
        width="100px"
        label="序号">
      </el-table-column>

      <el-table-column
        prop="qrytime"
        header-align="center"
        align="center"
        width="160px" 
        label="查询时间">
      </el-table-column>


      <el-table-column
        prop="serviceno"
        header-align="center"
        align="center"
         width="160px" 
        label="业务件号">
      </el-table-column>
      <el-table-column
        prop="realtyno"
        header-align="center"
        align="center"
         :show-overflow-tooltip="true"
        width="300px" 
        label="登记证明号">
      </el-table-column>
      <el-table-column
        prop="dyfsTranslate"
        header-align="center"
        align="center"
         width="100px" 
        label="抵押方式">
      </el-table-column>

      <el-table-column
        prop="dyghTranslate"
        header-align="center"
        align="center"
         width="160px" 
        label="带抵押过户标识">
      </el-table-column>


      <el-table-column
        prop="bdbzqse"
        header-align="center"
        align="center"
       width="130px"   
        label="被担保债权数额">
      </el-table-column>
      <el-table-column
        prop="zwlxqssj"
        header-align="center"
        align="center"
         width="160px" 
        label="债务起始时间">
      </el-table-column>
      <el-table-column
        prop="zwlxjssj"
        header-align="center"
         width="160px"  
        align="center"
        label="债务结束时间">
      </el-table-column>
      <el-table-column
        prop="dbfw"
        header-align="center"
        align="center"
          width="130px" 
        label="抵押担保范围">
      </el-table-column>
    </el-table>

    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">

      <el-table-column
        prop="seqno"
        header-align="center"
        align="center"
        width="100px"
        label="序号">
      </el-table-column>

      <el-table-column
        prop="qrytime"
        header-align="center"
        align="center"
        width="160px" 
        label="查询时间">
      </el-table-column>


      <el-table-column
        prop="serviceno"
        header-align="center"
        align="center"
         width="160px" 
        label="业务件号">
      </el-table-column>
      <el-table-column
        prop="realtyno"
        header-align="center"
        align="center"
         :show-overflow-tooltip="true"
        width="300px" 
        label="登记证明号">
      </el-table-column>
      <el-table-column
        prop="dyfsTranslate"
        header-align="center"
        align="center"
         width="100px" 
        label="抵押方式">
      </el-table-column>

      <el-table-column
        prop="dyghTranslate"
        header-align="center"
        align="center"
         width="160px" 
        label="带抵押过户标识">
      </el-table-column>


      <el-table-column
        prop="bdbzqse"
        header-align="center"
        align="center"
       width="130px"   
        label="被担保债权数额">
      </el-table-column>
      <el-table-column
        prop="zwlxqssj"
        header-align="center"
        align="center"
         width="160px" 
        label="债务起始时间">
      </el-table-column>
      <el-table-column
        prop="zwlxjssj"
        header-align="center"
         width="160px"  
        align="center"
        label="债务结束时间">
      </el-table-column>
      <el-table-column
        prop="dbfw"
        header-align="center"
        align="center"
          width="130px" 
        label="抵押担保范围">
      </el-table-column>

      <el-table-column
        fixed="left"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.serialno)">显示查询信息</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="datepicker.pageOptions"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <bdc-dy-query v-if="dyQueryVisible" ref="dyQuery" ></bdc-dy-query>    
  </div>
</template>

<script>
  import AddOrUpdate from './bdcrealtyinfo-add-or-update'
  import BdcDyQuery from './bdc-dy-query'
  export default {
    data () {
      return {
        dataForm: {
          serviceno: '',
          realtyno: '',
          obankid: '',
          isdygh: '',
          isDyghList: []
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
        dyQueryVisible: false
      }
    },
    components: {
      AddOrUpdate,
      BdcDyQuery
    },
    activated () {
      this.getDataList()
    },
    methods: {
      export2Excel(id){
          this.datepicker.export2Excel(id, this, '抵押物查询.xlsx')
      },
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/bdc/bdcrealtyinfo/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'realtyno': this.dataForm.realtyno,
             'serviceno': this.dataForm.serviceno,
              'obankid': this.dataForm.obankid,
              'isdygh': this.dataForm.isdygh
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
            this.dataForm.isDyghList = data.isDyghList
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      dyQueryHandle (id) {
        this.dyQueryVisible = true
        this.$nextTick(() => {
          this.$refs.dyQuery.init(id)
        })
      },
      // 删除
      deleteHandle (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.serialno
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/bdc/bdcrealtyinfo/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
    }
  }
</script>
